function compute_intersectiion(arr1, arr2, cb) {
    //pick the bigger one
    let bigger = arr1.length > arr2.length ? arr1 : arr2;
    let smaller = bigger == arr1 ? arr2 : arr1;
    let biglen = bigger.length;
    let smlen = smaller.length;

    let sidx = 0;
    const size = 10;
    let results = [];
    function sub_compute_intersection() {
        let i = sidx;
        for(; i < (sidx + size) && i < biglen; i++) {
            for(let j = 0; j < smlen ; j++) {
                if(bigger[i] == smaller[j]) {
                    results.push(smaller[j]);
                    break;
                }
            }
        }
        if(i >= biglen) {
            cb(null, results);
        }else {
            sidx += size;
            process.nextTick(sub_compute_intersection);
        }
    }
    sub_compute_intersection();

}

let arr1 = [];
for(let i = 0; i < 100; i++) {
    arr1.push(i);
}
let arr2 = [];
for(let i = 0; i < 20; i++) {
    arr2.push(i);
}
// console.log(arr1);
// console.log(arr2);
compute_intersectiion(arr1, arr2, (err, results) => {
    if(err) {
        console.log("some err happens");
        return;
    }
    console.log("result is");
    console.log(results);
})